/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainFrame.java
 *
 * Created on 29/04/2012, 06:30:08 PM
 */

package frontera;

import Test.MovieCenterTest;
import control.validar;
import javax.swing.JOptionPane;

/**
 *
 * @author Juan
 */
public class MainFrame extends javax.swing.JFrame {

    /** Creates new form MainFrame */
    public MainFrame() {
        initComponents();
        MovieCenterTest test = new MovieCenterTest();
        test.test();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        PanelPrincipal = new javax.swing.JPanel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        PanelPrincipal.setLayout(new java.awt.BorderLayout());

        jMenu1.setText("Buscar/Editar");
        jMenu1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jMenu1MouseClicked(evt);
            }
        });
        jMenu1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenu1ActionPerformed(evt);
            }
        });
        jMenuBar1.add(jMenu1);

        jMenu2.setText("Administrador");
        jMenu2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jMenu2MouseClicked(evt);
            }
        });
        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(PanelPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, 618, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(PanelPrincipal, javax.swing.GroupLayout.PREFERRED_SIZE, 734, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jMenu1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenu1MouseClicked
        BuscarEditar BuscarEditarPanel=new BuscarEditar(this);
        PanelPrincipal.setVisible(false);
        PanelPrincipal.removeAll();
        PanelPrincipal.add(BuscarEditarPanel);
        PanelPrincipal.setVisible(true);
    }//GEN-LAST:event_jMenu1MouseClicked

    public void buscarEditarPeliculas(){
        searchMovie searchMovie = new searchMovie();
        PanelPrincipal.setVisible(false);
        PanelPrincipal.removeAll();
        PanelPrincipal.add(searchMovie);
        PanelPrincipal.setVisible(true);
        setSize(600, 580);
    }
    
    public void buscarEditarDirectores(){
        searchDirector searchDirector = new searchDirector();
        PanelPrincipal.setVisible(false);
        PanelPrincipal.removeAll();
        PanelPrincipal.add(searchDirector);
        PanelPrincipal.setVisible(true);
    }
    
    public void buscarEditarActores(){
        searchActor searchActor = new searchActor();
        PanelPrincipal.setVisible(false);
        PanelPrincipal.removeAll();
        PanelPrincipal.add(searchActor);
        PanelPrincipal.setVisible(true);
    }
    
    public void buscarEditarArtistas(){
        searchArtist searchArtist = new searchArtist();
        PanelPrincipal.setVisible(false);
        PanelPrincipal.removeAll();
        PanelPrincipal.add(searchArtist);
        PanelPrincipal.setVisible(true);
    }
    private void jMenu2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenu2MouseClicked
        String contraseña=JOptionPane.showInputDialog(this,"Ingrese la contaseña de administrador");
        validar valida=new validar();
        boolean respuesta=valida.validarUsuario(contraseña);
        if(respuesta) {
            AdminPanel movie = new AdminPanel(this);
            PanelPrincipal.setVisible(false);
            PanelPrincipal.removeAll();
            PanelPrincipal.add(movie);
            PanelPrincipal.setVisible(true);
        }
        else if(respuesta==false)JOptionPane.showMessageDialog(this, "Contraseña errada");
    }//GEN-LAST:event_jMenu2MouseClicked

    private void jMenu1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenu1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenu1ActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new MainFrame().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel PanelPrincipal;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    // End of variables declaration//GEN-END:variables

    void crearPeliculas() {
        createMovie movie=new createMovie();
        PanelPrincipal.setVisible(false);
        PanelPrincipal.removeAll();
        PanelPrincipal.add(movie);
        PanelPrincipal.setVisible(true);
        setSize(600, 580);
    }

    void crearActor() {
        createActor actor=new createActor();
        PanelPrincipal.setVisible(false);
        PanelPrincipal.removeAll();
        PanelPrincipal.add(actor);
        PanelPrincipal.setVisible(true);
        setSize(600, 580);
    }

    void crearDirectores() {
        createDirector movie=new createDirector();
        PanelPrincipal.setVisible(false);
        PanelPrincipal.removeAll();
        PanelPrincipal.add(movie);
        PanelPrincipal.setVisible(true);
        setSize(600, 580);
    }

}
